package org.zjx;


import org.zjx.account.enums.Sects;
import org.zjx.client.SocketClient;
import org.zjx.command.entity.Address;
import org.zjx.command.model.RouteProperties;
import org.zjx.command.service.PropService;
import org.zjx.command.service.RouteService;
import org.zjx.core.SocketConfig;
import org.zjx.prop.domain.enums.SlotType;
import org.zjx.prop.domain.model.ItemInstance;
import org.zjx.prop.domain.model.ItemSlot;
import org.zjx.route.model.Route;

import java.util.List;

public class Main {
    public static String playerId = "123456";

    public static void main(String[] args) {
        SocketConfig clientConfig = new SocketConfig();
        clientConfig.setServerHost("localhost");
        clientConfig.setPort(8889);
        clientConfig.setRequestTimeout(5000); // 5秒超时
        clientConfig.setDebugEnabled(true);

        SocketClient client = new SocketClient(clientConfig);
        client.connect();

        testRoute(client);
//        testProp(client);

        client.disconnect();
    }


    public static void testRoute(SocketClient client) {
        RouteService routeService = client.createProxy(RouteService.class);

        RouteProperties routeProperties = new RouteProperties();
        routeProperties.setPlayerId("123456");
        routeProperties.setAddress(new Address("长安城",34,67));
        routeProperties.setEndAddress(new Address("大唐境外",454,76));
        routeProperties.setSects(Sects.YIN_CAO_DI_FU);

        List<Route> routes = routeService.findPath(routeProperties);
        for(Route route : routes){
            System.out.println(route.getDescription());
        }

//        System.out.println();
//        System.out.println();
//        Route route = routeService.findPathByOne("123456", new Address("长安城", 34, 67), new Address("龙宫", 54, 76));
//        System.out.println(route.getDescription());
//        client.disconnect();
    }


    public static void testProp(SocketClient client) {
        PropService propService = client.createProxy(PropService.class);

//        propService.handOff(playerId,SlotType.INVENTORY,SlotType.EXTENDED_INVENTORY);

//        List<ItemInstance> instances = propService.getPlayerItemsBySlotType(playerId, SlotType.EXTENDED_INVENTORY);


        List<ItemInstance> needGather = propService.needGather(playerId, SlotType.EXTENDED_INVENTORY);

        for (ItemInstance instance : needGather) {
            System.out.println(instance);
        }

        System.out.println("=====================================");
        List<ItemSlot> itemSlots = propService.getItemSlots(playerId, needGather);
        for (ItemSlot itemSlot : itemSlots) {
            System.out.println(itemSlot);
        }

//        ItemInstance instance = needGather.get(0);
//        instance.setGather(true);
//
//        boolean result = propService.updateItem(playerId, instance);
//        System.out.println("更新"+result);
    }
}